package Game;

/**
 * Effect with duration
 *
 */
public abstract class Buff extends Effect {
	/**
	 * Buff's duration, i.e. number of remaining turns it will last. 
	 */
	private int duration;
	
	public Buff(String _name, String _desc, int _type) {
		super(_name, _desc, _type);
	}
	
	public Buff(String _name, String _desc, int _type, int[] _triggers) {
		super(_name, _desc, _type, _triggers);
	}
	
	public int getDuration() {
		return duration;
	}
	
	public void increaseDuration(int diff) {
		decreaseDuration(-diff);
	}
	
	public void decreaseDuration(int diff) {
		duration -= diff;
	}
	
	public void decrementDuration() {
		decreaseDuration(1);
	}
	
	public void onTurnEnd(IAffectable affectable) {
		decrementDuration();
		if (duration <= 0)
			onDismiss(affectable);
	}
}
